Learn R Programming

R.utils (version 2.3.0)

PERCENT< -PERCENT: Assignment operator for delayed assignments ('lazy future')

Description

This infix operator is deprecated. For an alternative, see %<-% part of the future package.

Assignment operator for delayed assignments ('lazy future') such that the expression on the right-hand side (RHS) is evaluated using "lazy future" (a call by future that has lazy evaluation semantics), which mean it "promised" to be evaluated when the value of the assigned variable (on left-hand side (LHS)) is retrieved but not before. This means that if the LHS variable is never retrieved / used, then the RHS expression will never be evaluated.

The "lazy evaluation" property of delayed assignments is in constrast to the "eager evaluation" property of regular assignments, which evaluate the RHS expression at the same time as the assignment take place, i.e. immediately.

The RHS expression will be evaluted in a local().

Usage

x %<-% value

Arguments

x
The variable name (possibly quoted).
value
The value to be assigned to x.

Value

Returns (invisibly) NULL. Note, contrary to <-(), it is not meaniful to do a %<-% b %<-% c %<-% 6.

See Also

Internally delayedAssign() is used.

Examples

Run this code
message("a %<-% ...")
a %<-% { message("Now assigning 'a'"); 1 }
message("b %<-% a")
b %<-% a
message("c %<-% b")
c %<-% b
message("d %<-% 2*c")
d <- 2*c

Run the code above in your browser using DataLab